﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;

namespace MegaMan
{
    class GameEntity
    {
        protected Texture2D entityImage;
        public Texture2D EntityImage
        {
            get { return entityImage; }
        }

        protected Vector2 entityPosition = Vector2.Zero;
        public Vector2 EntityPosition
        {
            get { return entityPosition; }
            set { entityPosition = value; }
        }

        private Rectangle? entitySourceRectangle;
        public Rectangle? EntitySourceRectangle
        {
            get { return entitySourceRectangle; }
            set { entitySourceRectangle = value; }
        }

        private Color entityColor = Color.White;
        public Color EntityColor
        {
            get { return entityColor; }
            set { entityColor = value; }
        }

        protected float entityRotation = 0;
        public float EntityRotation
        {
            get { return entityRotation; }
            set { entityRotation = value; }
        }

        private Vector2 entityOrigin = Vector2.Zero;
        public Vector2 EntityOrigin
        {
            get { return entityOrigin; }
            set { entityOrigin = value; }
        }

        private float entityScale = 1;
        public float EntityScale
        {
            get { return entityScale; }
            set { entityScale = value; }
        }

        private SpriteEffects entitySpriteEffects = SpriteEffects.None;
        public SpriteEffects EntitySpriteEffects
        {
            get { return entitySpriteEffects; }
            set { entitySpriteEffects = value; }
        }

        private float entityLayerDepth = 0;
        public float EntityLayerDepth
        {
            get { return entityLayerDepth; }
            set { entityLayerDepth = value; }
        }

        private bool visible;
        public bool Visible
        {
            get { return visible; }
            set { visible = value; }
        }


        public Rectangle CollisionRectangle
        {
            get
            {
                return new Rectangle((int)entityPosition.X, (int)entityPosition.Y, entityImage.Width, entityImage.Height);
            }
        }

        public GameEntity()
        {

        }

        public virtual void Update(GameTime gameTime)
        {

        }

        public virtual void Draw(SpriteBatch spriteBatch)
        {
            if (visible)
                spriteBatch.Draw(entityImage, entityPosition, entitySourceRectangle, entityColor, entityRotation, entityOrigin, entityScale, entitySpriteEffects, entityLayerDepth);
        }

        public void entityMoveVectorBased(Vector2 movementSpeed)
        {
            entityPosition += movementSpeed;
        }

        public void entityMovePositiveX(float momentAmmount)
        {
            entityMoveVectorBased(new Vector2(momentAmmount, 0));
        }

        public void entityMoveNegativeX(float momentAmmount)
        {
            entityMoveVectorBased(new Vector2(-momentAmmount, 0));
        }

        public void entityMovePositiveY(float momentAmmount)
        {
            entityMoveVectorBased(new Vector2(0, momentAmmount));
        }

        public void entityMoveNegativeY(float momentAmmount)
        {
            entityMoveVectorBased(new Vector2(0, -momentAmmount));
        }

        public void rotateEntityClockwise(float rotationAmmount)
        {
            entityRotation += rotationAmmount;
        }

        public void rotateEntityCounterClockwise(float rotationAmmount)
        {
            entityRotation -= rotationAmmount;
        }
    }
}
